//
//  OrderTextField.m
//  quxiangtao
//
//  Created by HHuajiang on 2018/12/11.
//  Copyright © 2018 shanhaijin. All rights reserved.
//

#import "OrderTextField.h"

@implementation OrderTextField

- (instancetype)initWithFrame:(CGRect)frame {
    if (self = [super initWithFrame:frame]) {
        self.font = [UIFont systemFontOfSize:14];
        self.textColor = Color000000;
        self.tintColor= [UIColor redColor];
//        [self setValue:Colorffeeee fo/rKeyPath:@"_placeholderLabel.textColor"];
        [self setValue:[UIFont systemFontOfSize:14] forKeyPath:@"_placeholderLabel.font"];
            // 不成为第一响应者
        [self resignFirstResponder];
        
    }
    return self;
}
/**
 * 当前文本框聚焦时就会调用
 */
//- (BOOL)becomeFirstResponder
//{
//        // 修改占位文字颜色
//    [self setValue:self.textColor forKeyPath:@"_placeholderLabel.textColor"];
//    return [super becomeFirstResponder];
//}

/**
 * 当前文本框失去焦点时就会调用
 */
//- (BOOL)resignFirstResponder
//{
//        // 修改占位文字颜色
//    [self setValue:[UIColor grayColor] forKeyPath:@"_placeholderLabel.textColor"];
//    return [super resignFirstResponder];
//}

    //控制placeHolder的位置
-(CGRect)placeholderRectForBounds:(CGRect)bounds
{
    CGRect inset = CGRectMake(bounds.origin.x+15, bounds.origin.y, bounds.size.width -15, bounds.size.height);
    return inset;
}

    //控制显示文本的位置
-(CGRect)textRectForBounds:(CGRect)bounds
{
    CGRect inset = CGRectMake(bounds.origin.x+15, bounds.origin.y, bounds.size.width -15, bounds.size.height);
    return inset;
}

    //控制编辑文本的位置
-(CGRect)editingRectForBounds:(CGRect)bounds
{
    CGRect inset = CGRectMake(bounds.origin.x +15, bounds.origin.y, bounds.size.width -15, bounds.size.height);
    return inset;
}

@end
